package com.rp.system.user.service;

import cn.hutool.core.lang.tree.Tree;
import com.rp.system.user.entity.SysPermission;
import com.baomidou.mybatisplus.extension.service.IService;
import com.rp.system.user.entity.SysRole;
import com.rp.system.user.model.SysPermissionTree;
import org.apache.ibatis.annotations.Param;

import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

/**
 * <p>
 * 菜单权限表 服务类
 * </p>
 *
 * @author vicente
 * @since 2020-11-24
 */
public interface SysPermissionService extends IService<SysPermission> {

    /**
     * @Author HuJingYu
     * @Date 9:59 2020-12-21
     * @Description 根据角色集合查询所有权限
     * @param roles
     * @return java.util.LinkedHashSet<SysPermission>
     */
    LinkedHashSet<SysPermission> findPermissionsByRoleId(Set<SysRole> roles);

    /**
     * @Author HuJingYu
     * @Date 10:01 2020-12-21
     * @Description 根据用户名查询权限树
     * @param username 用户名
     * @return java.util.LinkedHashSet<SysPermissionTree>
     */
    List<Tree<String>> findSysPermissionsByUserId(String username) throws IllegalAccessException;

    /**
     * @Author HuJingYu
     * @Date 10:02 2020-12-21
     * @Description 根据用户名查询权限树 缓存处理
     * @return java.util.LinkedHashSet<SysPermissionTree>
     */
    List<Tree<String>> findSysPermissionsByUserIdInCache() throws IllegalAccessException;


    public List<Tree<String>> getTreeList(List<SysPermission> list,Boolean IsSysPermissionTree) throws IllegalAccessException;

    /**
     * @Author HuJingYu
     * @Date 16:07 2021-03-08
     * @Description 根据部门编码查询对应 部门权限
     * @param orgCode
     * @return java.util.LinkedHashSet<com.rp.system.user.entity.SysPermission>
     */
    LinkedHashSet<SysPermission> getPermissionByDepartOrgCode(@Param("orgCode") String orgCode);

    LinkedHashSet<SysPermission> getPermissionByDepartParentId(@Param("parentId") String parentId);

    /**
     * @Author HuJingYu
     * @Date 18:04 2021-03-09
     * @Description 根据权限IDs 查询权限perms
     * @param roleIdList
     * @return java.util.List<java.lang.String>
     */
    List<String> getPermissionPermsByRoleIds(@Param("roleIdList") List<String> roleIdList);

}
